//
//  ChecklistHeaderWithSectionImageCell.swift
//  GreenDeal
//
//  Created by Moennig Q on 11/2/2023.
//

import UIKit
import SnapKit
class ChecklistHeaderWithSectionImageCell: UITableViewCell {
    let sectionTitleLabel = ContentLabel(R.font.interRegular(size: 12),hexStr: "#292D3299")
    let topImageView = UIImageView()
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setUpviews()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    func setUpviews(){
        self.backgroundColor = UIColor(hexStr: Constant.TransparentColorHexStr)
        self.contentView.backgroundColor = UIColor(hexStr: Constant.TransparentColorHexStr)
        self.selectionStyle = .none
        //section Title
        self.contentView.addSubview(sectionTitleLabel)
        sectionTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(Constant.AllOutMargin)
            make.left.equalTo(24)
            make.width.height.greaterThanOrEqualTo(0)
        }
        //topImageView
        topImageView.drawCorner(byRoundingCorners: [.topLeft,.topRight])
        topImageView.contentMode = .scaleAspectFit
        self.contentView.addSubview(topImageView)
        topImageView.snp.makeConstraints { make in
            make.top.equalTo(sectionTitleLabel.snp.bottom).offset(Constant.AllOutMargin / 2)
            make.left.equalTo(12)
            make.right.equalTo(-12)
            make.height.equalTo(80)
            make.bottom.equalToSuperview()
        }
    }
    func setData(_ title: String, section: CheckListSectionType){
        sectionTitleLabel.text = title
        if section == .signatures{
            topImageView.backgroundColor = UIColor(hexStr: "#1B6F43")
            topImageView.image = R.image.jobdetail_signatures_top_icon()
        }else if section == .otherChecklist {
            topImageView.backgroundColor = UIColor(hexStr: "#346096")
            topImageView.image = R.image.jobdetail_checklist_cell_top_icon()
        }else if section == .scan{
            topImageView.backgroundColor = UIColor(hexStr: "#688F4E")
            topImageView.image = R.image.jobdetail_preinstallation_top_icon()
        }
    }
}
